package cn.com.bluemoon.daps.sync.vo.applypublish;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.io.Serializable;

/**
 * @author Jarod.Kong
 * @date 2021/7/30 9:59
 */
@Data
public class TableApplyPublishReportVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("模型id")
    private String modelId;

    @ApiModelProperty("表id")
    private String tableId;

    @ApiModelProperty("表名")
    private String tableName;

    @ApiModelProperty("建表语句")
    private String createTableSql;

    @ApiModelProperty("可执行，true执行成功，false执行失败")
    private Boolean canExec;

    @ApiModelProperty("信息")
    private String msg;

    @ApiModelProperty("信息类型")
    private Type type;

    public enum Type {
        NORMAL(1, "普通类型错误"),
        SQL_VALID(2, "SQL检查错误");

        private final int code;
        private final String desc;

        Type(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("modelId", modelId)
                .append("tableId", tableId)
                .append("createTableSql", createTableSql)
                .append("canExec", canExec)
                .append("msg", msg)
                .append("type", type)
                .toString();
    }
}
